home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / libgutil / objdraw.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  142 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    objdraw -
  19.  *        Some utilities for drawing geometric objects. 
  20.  *
  21.  *                Paul Haeberli - 1985
  22.  */
  23. #include "obj.h"
  24. #include "gl.h"
  25.  
  26. static unsigned short raster[] = {
  27.     0xf800, 0x8800, 0x8800, 0x8800, 0xf800,
  28.     0x7000, 0x8800, 0x8800, 0x8800, 0x7000,
  29. };
  30.  
  31. static Fontchar chars[] = {
  32.     {0,0,0,0,0,0},
  33.     {0,5,5,-2,-2,5},
  34.     {5,5,5,-2,-2,5},
  35. };
  36.  
  37. drawmarks(obj)
  38. object *obj;
  39. {
  40.     int i, j;
  41.     point *apnt;
  42.     static int firsted = 0;
  43.  
  44.     if(!firsted) {
  45.     defrasterfont(1,7,3,chars,10,raster);
  46.     firsted = 1;
  47.     }
  48.     font(1);
  49.     while(obj) {
  50.     apnt = obj->points;
  51.     while(apnt) {
  52.        putsym(apnt);
  53.        apnt = apnt->next;
  54.     }
  55.     obj = obj->next;
  56.     }
  57.     font(0);
  58. }
  59.  
  60. putsym(pnt)
  61. point *pnt;
  62. {
  63.     char buf[2];
  64.  
  65.     cmov2(pnt->x,pnt->y);
  66.     if(pnt->type == PNT_SQUARE)
  67.     buf[0] = 1;
  68.     else
  69.     buf[0] = 2;
  70.     buf[1] = 0;
  71.     charstr(buf);
  72.     move(pnt->x,pnt->y,pnt->z);
  73. }
  74.  
  75. drawobj(obj)
  76. object *obj;
  77. {
  78.     point *apnt;
  79.  
  80.     while(obj) {
  81.     if(obj->points != NULL) {
  82.         if(obj->type == OBJ_POINTS) {
  83.         apnt = obj->points;
  84.         while(apnt) {
  85.            pnt(apnt->x,apnt->y,apnt->z);
  86.            apnt = apnt->next;
  87.         }
  88.         } else if(obj->type == OBJ_LINE) {
  89.         apnt = obj->points;
  90.         move(apnt->x,apnt->y,apnt->z);
  91.         while(apnt) {
  92.            draw(apnt->x,apnt->y,apnt->z);
  93.            apnt = apnt->next;
  94.         }
  95.         } else if(obj->type == OBJ_LOOP) {
  96.         apnt = obj->points;
  97.         bgnclosedline();
  98.         while(apnt) {
  99.            v3f(&apnt->x);
  100.            apnt = apnt->next;
  101.         }
  102.         endclosedline();
  103.         } else if(obj->type == OBJ_POLYGON) {
  104.         apnt = obj->points;
  105.         bgnpolygon();
  106.         while(apnt) {
  107.            v3f(&apnt->x);
  108.            apnt = apnt->next;
  109.         }
  110.         endpolygon();
  111.         } else 
  112.         printf("drawobj: blat\n");
  113.     }
  114.     obj = obj->next;
  115.     }
  116. }
  117.  
  118. fillobj(obj)
  119. object *obj;
  120. {
  121.     drawobj(obj);
  122. }
  123.  
  124. drawtwixt(obj1, obj2)
  125. object *obj1, *obj2;
  126. {
  127.     point *pt1, *pt2;
  128.  
  129.     while(obj1 && obj2) {
  130.     pt1 = obj1->points;
  131.     pt2 = obj2->points;
  132.     while(pt1 && pt2) {
  133.         move(pt1->x,pt1->y,pt1->z);
  134.         draw(pt2->x,pt2->y,pt2->z);
  135.         pt1 = pt1->next;
  136.         pt2 = pt2->next;
  137.     }
  138.     obj1 = obj1->next;
  139.     obj2 = obj2->next;
  140.     }
  141. }
  142.